﻿package cn.edu.zjusc.Webservice;
import java.util.List;

import javax.ejb.Stateless;
import javax.jws.*;
import javax.jws.soap.SOAPBinding;
import javax.persistence.*;



import org.jboss.wsf.spi.annotation.WebContext;

import cn.edu.zjusc.POJO.*;
import cn.edu.zjusc.Util.CacheManager;

@Stateless
@WebService( name = "UniversityCodeService", serviceName = "UniversityCodeService")   
@SOAPBinding(style = SOAPBinding.Style.RPC)
@WebContext (contextRoot="/ZJUSCIX/Service", urlPattern="/UniversityCodeService") 
public class UniversityCodeService {
	
	
	public List<UniversityCode> GetAllUniversityCodeInfoById(@WebParam(name="id")int id) {
		return CacheManager.getUniversityInOneProvince(id);
	}
	
	/**
	 * 该方法目前废弃
	 * @param id
	 * @return
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public List<UniversityCode> GetUniversityById(@WebParam(name="id")int id) {

		EntityManagerFactory emf =Persistence.createEntityManagerFactory("zjusc");
		EntityManager em=emf.createEntityManager();

		Query query=em.createQuery("from UniversityCode e where e.unicd_id="+id);
		List cdList=query.getResultList();
		
		em.close();
		emf.close();
		return cdList;
	}
}
